{% extends 'TopxiaWebBundle:My:layout.html.twig' %}

{% block title %}我的话题 - {{ parent() }}{% endblock %}

{% set side_nav = 'my-discussions' %}

{% block main %}

<div class="panel panel-default panel-col">
  <div class="panel-heading">我的话题</div>

  <div class="panel-body">
    {% include 'TopxiaWebBundle:MyThread:tab.html.twig'%}
    {% if threads %}

    {% set type = type|default('discussion') %}

    <ul class="media-list">
      {% for thread in threads %}
       {% if classrooms %}
        {% set classroom = classrooms[thread.targetId]|default(null) %}
        <li class="media">
            <div class="media-body">
              {% if thread.postNum > 0 %}
                <span class="badge pull-right" style="margin-top:15px;">{{ thread.postNum }}</span>
              {% endif %}
              <div class="mbm">
                {% if thread.type == 'question' %}
                  <span class="label label-info" title="问答帖">问</span>
                {% endif  %}

                <a href="{{ path('classroom_thread_show', {classroomId:thread.targetId, threadId:thread.id}) }}"><strong>{{ thread.title }}</strong></a>

                {% if thread.nice %}
                  <span class="label label-warning" title="精华帖">精</span>
                {% endif %}

              </div>
              <div class="text-muted text-normal">
                {% if classroom %}
                  <span>发表于{{ setting('classroom.name')|default("班级") }}<a href="{{ path('classroom_show', {id:classroom.id}) }}" class="link-muted">{{ classroom.title }}</a></span>
                {% else %}
                  <span>{{ setting('classroom.name')|default("班级") }}已删除</span>
                {% endif %}
                <span class="bullet">•</span>
                {% if thread.postNum > 0 %}
                  {% set poster = users[thread.lastPostUserId] %}
                  <span>最后回复 {{ web_macro.user_link(poster, 'link-muted') }}</span>
                  ,
                  <span>{{ thread.lastPostTime|smart_time }}</span>
                  <span class="bullet">•</span>
                {% endif %}
                <span>{{ thread.hitNum }}浏览</span>
              </div>
            </div>
          </li>
        {% else %}
          {% if type == 'question' %}
            <li class="empty">你还没提过问题</li>
          {% else %}
            <li class="empty">你还没发表过话题</li>
          {% endif %}

        {% endif %}

      {% endfor %}

    </ul>
    <nav class="text-center">
      {{ web_macro.paginator(paginator) }} 
    </nav>

    {% else %}
      <div class="empty">你还没有发表过话题</div>
    {% endif %}
  </div>
</div>
{% endblock %}